package org.example.yunshu.demos.model;

import lombok.Data;

@Data
public class Result<T> {
    private Integer code ; // 200成功, -1 发生错误 , -2 未登录
    private String errMsg ;// 错误原因 ;
    private T data ; //数据

    public  static  <T> Result<T>  success(T data){
        Result<T> result = new Result<>() ;
        result.setCode(200);
        result.setData(data);
        return result ;
    }
    public   static  <T> Result<T>  error(String errMsg){
        Result<T> result = new Result<>() ;
        result.errMsg = errMsg ;
        result.setCode(-1);
        return result ;
    }
    public  static  <T> Result<T>  unLogin(){
        Result<T> result = new Result<>() ;
        result.setCode(-2);
        return result ;
    }

}

